package marseillaisdu90.student_life;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class ObjetAdapter extends BaseAdapter {
    private Menu_Inventaire mi;

    public ObjetAdapter(Menu_Inventaire mi) {
        this.mi = mi;
    }

    public int getCount() {
        return MonApplication.modele.inv.nbObjet();
    }

    public Object getItem(int position) {
        return null;
    }

    public long getItemId(int position) {
        return 0;
    }

    // create a new ImageView for each item referenced by the Adapter
    public View getView(final int position, View convertView, ViewGroup parent) {
        final ImageView imageView;
        if (convertView == null) {  // if it's not recycled, initialize some attributes
            imageView = new ImageView(mi);
            imageView.setLayoutParams(new GridView.LayoutParams(50, 50));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(8, 8, 8, 8);
            
            /*imageView.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					imageView.setBackgroundColor(Color.RED);
					mi.mettreAJourDescription(MonApplication.modele.inv.getObjet(position));
				}
			});*/
        } else {
            imageView = (ImageView) convertView;
        }
        
        imageView.setImageResource(MonApplication.modele.inv.getObjet(position).getChemin_imageObj());
        return imageView;
    }

    // references to our images
    private Integer[] mThumbIds = {
            R.drawable.casquette, R.drawable.chapeau,
            R.drawable.kitkat
    };
}